package com.quectel.core.module.schedulingapply.dto;

import com.quectel.core.module.file.vo.FileDataVO;
import com.quectel.core.module.schedulingapply.dto.vo.SchedulingTimeVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @author zhangheng
 * @email nolan.zhang@quectel.com
 * @date 2023/07/13 19:14
 */
@Data
@Schema
public class SchedulingApplyRecordDto implements Serializable {

    /**
     * id
     */
    @Schema(description = "id")
    private Long id;

    /**
     * 租户id
     */
    @Schema(description = "租户id")
    private Long tenantId;

    /**
     * 小区id
     */
    @Schema(description = "小区id")
    private Long villageId;

    /**
     * 审批单号
     */
    @Schema(description = "审批单号")
    private String orderNo;

    /**
     * 申请人id
     */
    @Schema(description = "申请人id")
    private Long applyDeptPersonId;

    /**
     * 申请类型
     */
    @Schema(description = "申请类型,字典值:SchedulingAuditPipelineType")
    private Byte applyType;

    /**
     * 表单数据json
     */
    @Schema(description = "表单数据json")
    private String formDataJson;

    /**
     * 审核总状态 -2已关闭-1已取消0待审核1审核通过2驳回3已签到
     */
    @Schema(description = "审核总状态 -2已关闭-1已取消0待审核1审核通过2驳回3已签到")
    private Byte status;

    /**
     * 状态变更时间
     */
    @Schema(description = "状态变更时间")
    private Date statusChangeTime;

    /**
     * 当前审核位置
     */
    @Schema(description = "当前审核位置")
    private Integer currentAtSeq;

    /**
     *
     */
    @Schema(description = "")
    private String creator;

    /**
     *
     */
    @Schema(description = "")
    private Date createTime;

    /**
     *
     */
    @Schema(description = "")
    private String editor;

    /**
     *
     */
    @Schema(description = "")
    private Date editTime;

    /************非数据库字段 start ************/

    @Schema(description = "表单详情")
    private BaseFormData formData;
    @Schema(description = "申请人姓名")
    private String villageName;

    @Schema(description = "申请人姓名")
    private String applyPersonName;
    @Schema(description = "申请类型名称")
    private String applyTypeName;

    @Schema(description = "部门名称")
    private String deptName;

    @Schema(description = "需要审核的标识")
    private Byte needAudit;

    @Schema(description = "审批日志")
    private List<SchedulingApplyRecordAuditLogDto> auditLogs;

    /************非数据库字段 end **************/

    /**
     * 基础申请信息
     */
    @Data
    @Schema
    public static class BaseFormData implements Serializable {
        @Schema(description = "申请人id")
        private Long personId;

        @Schema(description = "事由")
        private String reason;

        @Schema(description = "是否包含附件0不包含,1包含")
        private Byte extFileFlag;

        @Schema(description = "附件地址")
        private List<FileDataVO> extFiles;
    }


    /**
     * 请假
     */
    @Data
    @Schema
    @EqualsAndHashCode(callSuper=true)
    public static class LeaveFormData extends BaseFormData implements Serializable {

        @Schema(description = "请假id")
        private Long leaveId;

        @Schema(description = "请假类型")
        private Byte type;

        @Schema(description = "请假开始时间")
        private String startTime;

        @Schema(description = "请假结束时间")
        private String endTime;

        @Schema(description = "请假时长,前端不用传,后台计算")
        private BigDecimal timeLength;

        @Schema(description = "时长,单位和请假最小时长单位一致,前端不用传,后台计算")
        private Byte timeUnit;

        @Schema(description = "申请时的假期余额")
        private BigDecimal historyBalance;

        @Schema(description = "申请时的假期余额单位")
        private Byte historyBalanceUnit;

        @Schema(description = "余额详情")
        private SchedulingTimeVO balanceDetail;

        /***************非数据库 ******************/
        @Schema(description = "申请时的假期余额单位")
        private String typeName;
        /***************非数据库 ******************/


    }

    /**
     * 销假
     */
    @Data
    @Schema
    @EqualsAndHashCode(callSuper=true)
    public static class ResumptionLeaveFormData extends BaseFormData implements Serializable {
        @Schema(description = "申请记录")
        private Long recordId;
        @Schema(description = "申请记录编号")
        private String orderNo;


        /*********非数据库字段*******/
        @Schema(description = "申请记录编号")
        private SchedulingApplyRecordDto schedulingApplyRecord;
        /*********非数据库字段*******/

    }

    /**
     * 补卡
     */
    @Data
    @Schema
    @EqualsAndHashCode(callSuper=true)
    public static class RenewCardFormData extends BaseFormData implements Serializable {

        @Schema(description = "补卡时间")
        private String renewCardTime;

    }


    /**
     * 加班
     */
    @Data
    @Schema
    @EqualsAndHashCode(callSuper=true)
    public static class OvertimeFormData extends BaseFormData implements Serializable {

        @Schema(description = "开始时间")
        private String startTime;

        @Schema(description = "结束时间")
        private String endTime;

        @Schema(description = "请假时长,前端不用传,后台计算")
        private BigDecimal timeLength;

        @Schema(description = "时长,单位和加班规则最小时长一致,前端不用传,后台计算")
        private Byte timeUnit;

    }

    /**
     * 外出
     */
    @Data
    @Schema
    @EqualsAndHashCode(callSuper=true)
    public static class OutFormData extends BaseFormData implements Serializable {
        @Schema(description = "")
        private String destination;

        @Schema(description = "开始时间")
        private String startTime;

        @Schema(description = "结束")
        private String endTime;

        @Schema(description = "请假时长,前端不用传,后台计算")
        private BigDecimal timeLength;

        @Schema(description = "时长,单位小时,前端不用传,后台计算")
        private Byte timeUnit;
    }


    /**
     * 出差
     */
    @Data
    @Schema
    @EqualsAndHashCode(callSuper=true)
    public static class TripFormData extends BaseFormData implements Serializable {
        @Schema(description = "出差行程列表")
        private List<TripData> tripDataList;
    }


    /**
     * 调班
     */
    @Data
    @Schema
    @EqualsAndHashCode(callSuper=true)
    public static class TransferClassFormData extends BaseFormData implements Serializable {
        @Schema(description = "调班类型,字典值:SchedulingApplyTransferClassType")
        private Byte type;

        @Schema(description = "替换员工id")
        private Long deptPersonId;

        @Schema(description = "替班日期")
        private String date;

        @Schema(description = "还班日期")
        private String returnDate;

    }

    @Data
    @Schema
    public static class TripData implements Serializable {
        @Schema(description = "序号,从0开始")
        private Integer seq;

        @Schema(description = "出发城市code")
        private String startCityCode;

        @Schema(description = "出发城市名称")
        private String startCityName;

        @Schema(description = "目的城市code")
        private String endCityCode;

        @Schema(description = "目的城市名称")
        private String endCityName;

        @Schema(description = "开始时间")
        private String startTime;

        @Schema(description = "结束时间")
        private String endTime;

        @Schema(description = "请假时长,前端不用传,后台计算")
        private BigDecimal timeLength;

        @Schema(description = "时长,单位小时,前端不用传,后台计算")
        private Byte timeUnit;

        @Schema(description = "交通工具,字典值:SchedulingTripTransportation")
        private Byte transportation;

        @Schema(description = "出行类型,字典值:SchedulingTripType")
        private Byte tripType;

    }


}
